package com.huitu.whht.ribbon_customer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
@EnableDiscoveryClient        // 开启服务发现功能
@EnableCircuitBreaker         // 开启断路器功能，进行容错管理
public class RibbonCustomerApplication {

    public static void main(String[] args) {
        SpringApplication.run(RibbonCustomerApplication.class, args);
    }


    @Bean   // 注册一个具有容错功能的RestTemplate
    @LoadBalanced// 开启负载均衡客户端
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
